using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos.mh_khac
{
    public partial class mh_select_nguyenlieu : DevExpress.XtraEditors.XtraForm
    {
        CultureInfo culture;
        public string str_manguyenlieu = "";
        public string str_tennguyenlieu = "";
        public string str_madvt = "";
        public string str_tendvt = "";
        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_select_nguyenlieu).Assembly);
                label21.Text = rm.GetString("tennguyenlieu", culture);
                bton_tim.Text = rm.GetString("tim", culture);
                bton_chon.Text = rm.GetString("chon", culture);
                bton_thoat.Text = rm.GetString("thoat", culture);
                col_nguyenlieu_ten.Caption = rm.GetString("nguyenlieu", culture);
                col_dvt_ten.Caption = rm.GetString("dvt", culture);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion

        public mh_select_nguyenlieu()
        {
            InitializeComponent();
            culture = CultureInfo.CurrentCulture;
        }

        private void bton_chon_Click(object sender, EventArgs e)
        {
            str_manguyenlieu = grid_nguyenlieu.GetRowCellDisplayText(grid_nguyenlieu.FocusedRowHandle, col_nguyenlieu_ma) + "";
            str_tennguyenlieu = grid_nguyenlieu.GetRowCellDisplayText(grid_nguyenlieu.FocusedRowHandle, col_nguyenlieu_ten) + "";
            str_madvt = grid_nguyenlieu.GetRowCellDisplayText(grid_nguyenlieu.FocusedRowHandle, col_dvt_ma) + "";
            str_tendvt = grid_nguyenlieu.GetRowCellDisplayText(grid_nguyenlieu.FocusedRowHandle, col_dvt_ten) + "";
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void mh_select_nguyenlieu_Load(object sender, EventArgs e)
        {

            cpublic ocpublic = new cpublic();
            string str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);

            luoi_nguyenlieu.DataSource = new thuvien().SP_SelectDataTable("sp_kho_nguyenlieu", new string[] { "@flag", "@choose", "@tennguyenlieu" }, new object[] { 1, 4, "" });
            txt_nguyenlieu_ten.Focus();
        }

        private void bton_tim_Click(object sender, EventArgs e)
        {
            string str_manguyenlieu =  txt_nguyenlieu_ten.Text;
            luoi_nguyenlieu.DataSource = new thuvien().SP_SelectDataTable("sp_kho_nguyenlieu", new string[] { "@flag", "@choose", "@tennguyenlieu" }, new object[] { 1, 4, str_manguyenlieu });
        }

        private void bton_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}